package com.cms.action;

import java.util.List;

import com.cms.entity.Article;
import com.cms.entity.Channel;
import com.cms.entity.Topic;
import com.cms.service.ArticleService;
import com.cms.service.ChannelService;
import com.cms.service.TopicService;
import com.opensymphony.xwork2.ActionSupport;

public class IndexAction extends ActionSupport {
	
	private int channelId;

	private TopicService topicService;
	private Topic topic;
	private List<Topic> topicList;
	
	private ChannelService channelService;
	private Channel channel;
	private List<Channel> channelList;
	
	private ArticleService articleService;
	private Article article;
	private List<Article> articleList;

	
	@Override
	public String execute(){
		return SUCCESS;
	}
	
	public String channel(){
		channelList = channelService.queryChannels(channel);
		return "channel";
	}
	
	public String topic(){
		topicList = topicService.queryTopics(topic);
		return "topic";
	}

	public String article(){
		articleList = articleService.queryArticles(article, 0, Integer.MAX_VALUE).getData();
		return "article";
	}
	
	public String channelArticles(){
		articleList = articleService.queryChannelArticles(channelId, 2);
		return "channelArticles";
	}
	
	public String headline(){
		articleList = articleService.queryHeadlineArticles(2);
		return "headline";
	}
	
	public String recommend(){
		articleList = articleService.queryRecommendArticles(10);
		return "recommend";
	}
	
	
	
	
	
	public TopicService getTopicService() {
		return topicService;
	}
	public void setTopicService(TopicService topicService) {
		this.topicService = topicService;
	}

	public Topic getTopic() {
		return topic;
	}
	public void setTopic(Topic topic) {
		this.topic = topic;
	}

	public List<Topic> getTopicList() {
		return topicList;
	}
	public void setTopicList(List<Topic> topicList) {
		this.topicList = topicList;
	}
	
	

	public int getChannelId() {
		return channelId;
	}

	public void setChannelId(int channelId) {
		this.channelId = channelId;
	}

	public ChannelService getChannelService() {
		return channelService;
	}

	public void setChannelService(ChannelService channelService) {
		this.channelService = channelService;
	}

	public Channel getChannel() {
		return channel;
	}

	public void setChannel(Channel channel) {
		this.channel = channel;
	}

	public List<Channel> getChannelList() {
		return channelList;
	}

	public void setChannelList(List<Channel> channelList) {
		this.channelList = channelList;
	}

	public ArticleService getArticleService() {
		return articleService;
	}

	public void setArticleService(ArticleService articleService) {
		this.articleService = articleService;
	}

	public Article getArticle() {
		return article;
	}

	public void setArticle(Article article) {
		this.article = article;
	}

	public List<Article> getArticleList() {
		return articleList;
	}

	public void setArticleList(List<Article> articleList) {
		this.articleList = articleList;
	}

	

}
